package com.kriss.portal.controller;

import com.kriss.portal.common.BaseController;
import com.kriss.portal.entity.JSONResult;
import com.kriss.portal.mybatis.entity.ContactInfo;
import com.kriss.portal.service.PortalService;
import org.junit.internal.runners.statements.Fail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 前端表单处理
 */
@Controller
@RequestMapping("/portal")
public class PortalController extends BaseController {
    @Autowired
    private PortalService portalService;

    /**
     * 管理员跳转到主页
     * @param contactInfo
     * @return
     */
    @RequestMapping("/home")
    public String home(){
        return "home";
    }

    /**
     * 表单数据的保存
     * @param contactInfo
     * @return
     */
    @RequestMapping("/save")
    public JSONResult saveRegist(ContactInfo contactInfo){
        int result =  portalService.saveRegist(contactInfo);
        if(result > 0)
            return new JSONResult(SUCCESS,SUCCESS_CODE);
        else
            return new JSONResult(FAILED,FAILED_CODE);
    }

}
